import React from "react";
import { message } from "antd";
import axios from "axios";
import qs from "qs";
export default class DelMeetingById extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  /**点击确认删除 */
  DelMeeting(id) {
    /**删除活动数据 */
    axios
      .post(
        "../weekmeeting/deletemeetingbyid.rst",
        qs.stringify({
          delArr: id,
        })
      )
      .then((res) => {
        let response = res.data;
        if (response.resultCode === 0) {
          /**重载表格数据 */
          message.success("删除活动成功");
          if (window.parent) {
            //本页面作为iframe打开时，操作完成后关闭窗口
            // window.parent.closeWindow();
            var iframe = document.createElement("iframe");
            iframe.setAttribute(
              "style",
              "position:absolute;left:-9999999px;top:-999999px;"
            );
            iframe.setAttribute(
              "src",
              "https://portal.zjbti.net.cn/_web/customized/scheduleCenter/closeWindow.html"
            );
            document.body.appendChild(iframe);
          }
        } else {
          message.error("删除活动失败");
        }
      })
      .catch((error) => {
        // message.error("删除活动失败");
      });
  }

  /** */
  getUrlParams = (name, str) => {
    const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`);
    const r = str.substr(1).match(reg);
    if (r != null) return decodeURIComponent(r[2]);
    return null;
  };

  componentDidMount() {
    /**url中含有id字段时，删除该id的会议*/
    let id = this.getUrlParams("id", this.props.location.search);
    if (id) {
      this.DelMeeting(id);
    }
  }
  render() {
    return <></>;
  }
}
